package com.sky.mapper;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;



@Mapper
public interface SetmealDishMapper {
    /**
     * 根据套餐id寻找菜品
     */
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> getDishBySetmealID(Long id);
    /**
     * 新增菜品和套餐的关系
     * @param setmealDishes
     */
    @Transactional
    void saveSetmealDish(List<SetmealDish> setmealDishes);

    /**
     * 删除对应的菜品
     * @param id
     */
    @Delete("delete  from setmeal_dish where setmeal_id = #{id}")
    void deleteDish(Long id);
    /**
     * 根据id查询套餐
     */
    @Select("select * from setmeal where id = #{id}")
    public Setmeal getSetmealByID(Long id);
}
